﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using XGE.Graphics;
using XGE.Physics;

namespace Engine_Project_1.GameObjects
{
    public class Ball : Sprite, iPhysicsObject
    {
        public Ball()
            : base("Fighter")
        { }
        public Ball(Vector2 Position)
            : base("Fighter", Position)
        {
            
        }



        public override void Initialize()
        {
            enabled = true;

            base.Initialize();
        }

        #region iPhysicsObject Members
        private PhysicsInfo physicsInfo = new PhysicsInfo();
        public bool Enabled
        {
            set { enabled = value; }
        }
        public PhysicsInfo PHYSICSINFO
        {
            get
            {
                return physicsInfo;
            }
            set
            {
                physicsInfo = value;
            }
        }
        
        public bool isEnabled
        {
            get { return enabled; }
        }

        public override void LoadContent()
        {
            base.LoadContent();
            InitializePhysicsInformation();
        }
        public override void Draw(Microsoft.Xna.Framework.GameTime gameTime)
        {
            Game.spriteBatch.Draw(texture, physicsInfo.collisionBox, TextureColor);
        }
        public void InitializePhysicsInformation()
        {
            physicsInfo.Initialize(Position, texture.Height, texture.Width);
            physicsInfo.Enabled = true;
            physicsInfo.Resitance = 0.7f;
        }

        public override void Update(Microsoft.Xna.Framework.GameTime gameTime)
        {
//            Position = physicsInfo.position;
            base.Update(gameTime);
        }
        #endregion

        #region iPhysicsObject Members

        PhysicsInfo iPhysicsObject.physicsInformation
        {
            get
            {
                return physicsInfo;
            }
            set
            {
                physicsInfo = value;
            }
        }

        bool iPhysicsObject.isEnabled
        {
            get {return enabled; }
        }

        #endregion
    }
}
